package com.extension.company.presenter.home;

import com.extension.company.model.entity.LeftListBean;
import com.extension.company.model.entity.RightListBean;
import com.extension.company.common.mvp.BasePresenter;
import com.extension.company.contract.main.MakeMoneyFragmentContract;
import com.extension.company.model.main.MakeMoneyFragmentMode;
import com.extension.company.view.home.MakeMoneyActivity;

import java.util.List;

/**
 * 商品的双list展示的列表
 */
public class MakeMoneyPrester extends BasePresenter<MakeMoneyFragmentMode, MakeMoneyFragmentContract.View> {


	@Override
	public MakeMoneyFragmentMode createModel() {
		return new MakeMoneyFragmentMode();
	}


	/**
	 * 左侧的list 列表
	 */
	public void requestLeftData() {
		model.leftData(new LeftCallBack() {
			@Override
			public void callBack(List<LeftListBean.DataBean.CategoryBean> list) {
				if (null != getView()) {
					((MakeMoneyActivity) getView()).leftData(list);
				}
			}
		});

	}

	/**
	 * 请求右侧的数据
	 *
	 * @param leftId 点击左侧的id
	 */
	public void requestRightData(int leftId,int count) {
		model.rightData(leftId,count, new RightCallBack() {
			@Override
			public void callBack(List<RightListBean.DataBean.GoodsBean> list,int leftId) {
              if (null!=getView()){
				  ((MakeMoneyActivity)getView()).rightData(list,leftId);
			  }
			}
		});
	}

	@Override
	protected void onViewDestroy() {

	}


	/**
	 * 左侧的回调  接口
	 */
	public interface LeftCallBack {
		void callBack(List<LeftListBean.DataBean.CategoryBean> list);
	}

	public interface RightCallBack {
		/**
		 * @param list 网络返回的json
		 * @param leftId  网络请求的左list id 值
		 */
		void callBack(List<RightListBean.DataBean.GoodsBean> list,int leftId);
	}
}
